//
//  ViewController.m
//  07--Delegate Block
//
//  Created by 冀永金 on 16/7/22.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"

@interface ViewController ()<SecondDelegate>
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIButton *nextButton;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    /**
     *  关于navigation中控制器的释放
      navigation中Viewcontrollers 数组，数组对象有引用计数 +1
     当controller入栈时，则被加入数组中，引用计数 + 1
     只要不出栈 就不会被释放
     A-> push -> B
     
     */
    self.nextButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.view addSubview:_nextButton];
    _nextButton.frame = CGRectMake(0, 0, 100,80);
    _nextButton.center = self.view.center ;
    [_nextButton setTitle:@"下一个" forState:UIControlStateNormal];
    _nextButton.backgroundColor = [UIColor cyanColor];
    [_nextButton addTarget:self action:@selector(handleNext:) forControlEvents:UIControlEventTouchUpInside];
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 80)];
    [self.view addSubview:_label];
    
    _label.center = CGPointMake(self.view.frame.size.width / 2, 150);
    _label.backgroundColor = [UIColor yellowColor];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)handleNext:(UIButton *)button {
    VCOfSecond *second = [[VCOfSecond alloc]init];
    second.delegate = self;
    [self.navigationController pushViewController:second animated:YES];
   
}
- (void)setText:(NSString *)text {
    self.label.text = text;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
